BackSumSeasonPanel = function(){
	var this_panel = this;
	
	var sum_text = new Ext.form.DisplayField({
		height : 25
	});
	
	var calculateSum = function(array){
		var sellSum=sum=businessman=techSupport=manager=team=0;
		for(var i=0; i<array.length;i++){
			var obj = array[i];
			sellSum += obj.sellSum;
			sum += obj.sum;
			businessman += obj.businessman;
			techSupport += obj.techSupport;
			manager += obj.manager;
			team += obj.team;
		}
		sum_text.setValue("<font color='blue'><b>【回款季度总计】</b></font>&nbsp;&nbsp;<b>回款金额:</b>"+sellSum+"&nbsp;&nbsp;<b>提成合计:</b>"+sum.toFixed(0)+"&nbsp;&nbsp;<b>业务经理:</b>"+businessman.toFixed(0)+"&nbsp;&nbsp;<b>技术支持:</b>"+techSupport.toFixed(0)+"&nbsp;&nbsp;<b>部门经理:</b>"+manager.toFixed(0)+"&nbsp;&nbsp;<b>团队:</b>"+team.toFixed(0));
	}
	
	this.listeners = {
			show : function(){
				this_panel.getTopToolbar().init();
			}
		};
	
	BackSumSeasonPanel.superclass.constructor.call(this, {
		title : "回款奖励季度合计",
		loadMask : true,
		stripeRows : true,
		enableHdMenu : false,
		sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
		colModel: new Ext.grid.ColumnModel({
			defaults : {
				align : "center",
				sortable : true
			},
			columns:[{header : "销售人员",dataIndex : "person.name",align:"left"},
			         {header : "回款金额",dataIndex : "sellSum"},
			         {header : "提成合计",dataIndex : "sum", xtype:"numbercolumn", format:"0"},
			         {header : "业务经理",dataIndex : "businessman", xtype:"numbercolumn", format:"0"}, 
			         {header : "技术支持",dataIndex : "techSupport", xtype:"numbercolumn", format:"0"}, 
			         {header : "部门经理",dataIndex : "manager", xtype:"numbercolumn", format:"0"}, 
			         {header : "团队",dataIndex : "team", xtype:"numbercolumn", format:"0"}]
		}),
		store :new Ext.data.JsonStore({
			fields : ['person.name','sellSum','sum','businessman','techSupport','manager','team']
		}),
		viewConfig: {
	        forceFit: true
		},
		tbar : new SeasonToolbar({
			panel : this_panel,
			url : "item/sumBySeason.action",
			type : "back",
			afterLoad : calculateSum
		}),
		bbar : [sum_text]
	})
};
Ext.extend(BackSumSeasonPanel, Ext.grid.GridPanel);
var backSumSeasonPanel = new BackSumSeasonPanel();